package com.chenglu.android.mine.wallet;

import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chenglu.android.R;
import com.chenglu.android.common.base.BaseActionBarActivity;
import com.chenglu.android.common.net.Constant;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.mine.bean.AmountTypeBean;
import com.chenglu.android.mine.bean.MoneyBean;
import com.chenglu.android.mine.beans.BeansRecordActivity;
import com.chenglu.android.mine.wallet.mvp.contract.WalletContract;
import com.chenglu.android.mine.wallet.mvp.presenter.WalletPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author: lyj
 * @Created: by Copyright 2023 6 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：余额
 */
public class WalletActivity extends BaseActionBarActivity<WalletPresenter> implements WalletContract.View {


    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_account_money)
    TextView tvAccountMoney;
    @BindView(R.id.tv_user_money)
    TextView tvUserMoney;
    @BindView(R.id.tv_total_bean)
    TextView tvTotalBean;
    @BindView(R.id.tv_tip)
    TextView tvTip;
    @BindView(R.id.tv_money_record)
    TextView tvMoneyRecord;
    @BindView(R.id.ll_loading_data)
    RelativeLayout llLoadingData;
    @BindView(R.id.tv_no_data)
    TextView tvNoData;
    @BindView(R.id.ll_loading_no_data)
    LinearLayout llLoadingNoData;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_wallet;
    }

    @Override
    protected void initView() {

        mPresenter = new WalletPresenter();
        mPresenter.attachView(this);
        setCenterText("我的余额");
        mPresenter.getMoneyDetails(getToken());


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void getAmountTypeList(AmountTypeBean bean) {

    }

    @Override
    public void getMoneyDetails(MoneyBean bean) {
        if(bean.getCode().equals(Constant.HTTPCODE200)){
            tvUserMoney.setText(Utils.formatZeroNumber(bean.getData().getUseMoneyTotal()));
            tvMoney.setText(Utils.formatZeroNumber(bean.getData().getMoney()));
            tvAccountMoney.setText(Utils.formatZeroNumber(bean.getData().getWaitMoney()));
            tvTip.setText(Html.fromHtml(bean.getData().getTips()));
        }

    }

    @OnClick(R.id.tv_money_record)
    public void onViewClicked() {
        startActivity(new Intent(this, BeansRecordActivity.class)
                .putExtra(BeansRecordActivity.AMOUNTTYPE,1));
    }
}
